/*
package com.luoc.base.service.impl;


import com.tqds.idol.dao.CfgFlowerGod;
import com.tqds.idol.mapper.CfgFlowerGodMapper;
import com.tqds.idol.mapper.ConfigMapper;
import com.tqds.idol.mapper.UserMapper;
import com.tqds.idol.utils.RedisUtils;
import com.tqds.idol.websocket.service.FlowerGodService;
import io.netty.channel.Channel;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.Map;

*/
/**
 * @Author: luoc
 * @Date: 2019/7/18 15:02
 *//*

public class FlowerGodServiceImpl implements FlowerGodService {

    //默认加速时间20秒
    private static int cfgSpeedUpTime = 20;
    // 离线的经验百分比
    private static double cfgOfflineRate = 0.2;
    // 结算心跳时间
    private static long hartSettle = 10;


*/
/*
    @Autowired
    RedisUtils redisUtils;

    @Autowired
    UserMapper userMapper;

    @Autowired
    CfgFlowerGodMapper cfgFlowerGodMapper;

    @Autowired
    ConfigMapper configMapper;
*//*


 */
/* @Override
    public Map<String,Object> genFlower(Integer uId) {
        if (uId == null){
            return null;
        }
        String redisKey = "user_flowergod_gen_" + uId;
       *//*
 */
/* if (redisUtils.incr(redisKey) > 1){
            return null;
        }
        redisUtils.expire(redisKey,2);
        // 获取用户信息
        Map<String,Object> userMap = userMapper.getUserInfoJoinCfgFlowerGodByUid(uId);*//*
 */
/*

        Long nowTime = System.currentTimeMillis()/1000;
        if ((nowTime - (Long)userMap.get("god_settle_time")) < hartSettle){
             return null;
        }

        int incFlower = (int) userMap.get("inc_flower_per_tenseconds");
        //  //如果当前时间 - 加速开始时间 <= self::$cfg_speedup_time，就当做加速计算
        //  ，相当于将后面的加速时间补到前面，只有在加速时间试结算时间整数倍时适用
        if (nowTime - (Long)userMap.get("god_speed_up_time") <= cfgSpeedUpTime ){
              //加倍的速率
              double speedRate = configMapper.selectGodFlowerSpeed();
              incFlower *= speedRate;
        }
        // 用户表更新
        Map<String,Object> flowerMap = new HashMap<>();
        flowerMap.put("incFlower",incFlower);
        flowerMap.put("uId",uId);
        flowerMap.put("nowTime",nowTime);
        userMapper.updateFlower(flowerMap);

        return userMap;
    }

    @Override
    public Map<String, Object> unlockGod(Integer uId, Integer id) {
        if (uId == null || uId <= 0){ return null; }
        Map<String,Object> map = userMapper.selectUserForUnlockGod(uId);
        CfgFlowerGod cfgFlowerGod = cfgFlowerGodMapper.selectByPrimaryKey(id);
        if ((int)map.get("flower") >= cfgFlowerGod.getNeedFlower()
          && (int)map.get("godLevel") + 1 == cfgFlowerGod.getLevel()){
                // 更新数据库
            Map<String,Object> paramsMap = new HashMap<>();
            paramsMap.put("id",uId);
            paramsMap.put("level",cfgFlowerGod.getLevel());
            paramsMap.put("flower",(int)map.get("flower")- cfgFlowerGod.getNeedFlower());
            userMapper.updateUserInfoForUnlockGod(paramsMap);
            map.put("godName",cfgFlowerGod.getName());
            map.put("godLevel",cfgFlowerGod.getLevel());
            map.put("myfower",(int)map.get("flower")- cfgFlowerGod.getNeedFlower());
            //map.put("secPerFlower",cfgFlowerGod.get)
            return map;
        }else{
            return null;
        }
    }

    @Override
    public void accelerate(Integer uId) {

    }

    @Override
    public void updateflowergod(Channel channel) {

    }

*//*

}
*/
